/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Model.Main.Wire;
import java.awt.Graphics2D;
import java.awt.Point;
import java.util.ArrayList;

/**
 *
 * @author Pales
 */
public class WireView {

    Wire wire = null;
    private ArrayList<Point> points = null;

    void addPoint(Point p) throws Exception {
        if (points == null) {
            points = new ArrayList<Point>();
        }
        if (wire != null) {
            throw new Exception("Wire already fixed!!!");
        }
        points.add(p);
    }

    void addWireModel(Wire w) {
        wire = w;
    }

    void paint(Graphics2D g2d) {
        if (points.size() > 1) {
            for (int i=1; i<points.size(); i++) {
                g2d.drawLine(points.get(i-1).x, points.get(i-1).y, points.get(i).x, points.get(i).y);
            }
        }
    }
}
